import request from '@/utils/request.js'

// 约束配置 API
export const constraintApi = {
  // 获取约束列表
  list() {
    return request({
      url: `/constraints/current-tenant`,
      method: 'get',
    })
  },
  // 新增约束：constraint_name 为字符串
  create(constraint_name) {
    return request({
      url: '/constraints/create',
      method: 'post',
      data: { constraintName:constraint_name }
    })
  },
  // 删除约束
  remove(id) {
    return request({
      url: `/constraints/del/${id}`,
      method: 'get'
    })
  },
  // 根据ID查询约束详细（包含规则/配置数据）
  getById(id) {
    return request({
      url: `/constraints/query`,
      method: 'get',
      params: { constraintId: id }
    })
  },
  // 保存约束配置
  save(schedulingPlanGenerateDto) {
    return request({
      url: '/constraints/save',
      method: 'post',
      data: {
        baseParameters: schedulingPlanGenerateDto.baseParameters,
        workTimeConfiguration: schedulingPlanGenerateDto.workTimeConfiguration,
        deviceConfiguration: schedulingPlanGenerateDto.deviceConfiguration
      }
    })
  }
}

export default constraintApi
